package com.ellricky.baselib.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import com.andr.common.util.ViewUtil;
import com.ellricky.baselib.R;

public class CommonDetailView extends FrameLayout {

    private Context mContext;
    private LinearLayout contentContainer;

    public CommonDetailView(Context context) {
        super(context);
        initView(context);
    }

    public CommonDetailView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    public CommonDetailView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context);
    }


    private void initView(Context context) {
        mContext = context;
        View.inflate(mContext, R.layout.base_common_detail_view, this);
        contentContainer = findViewById(R.id.content_container);
    }


    public void setContentView(int contentRes) {
        contentContainer.removeAllViews();
        if (contentRes <= 0) return;
        contentContainer.addView(ViewUtil.createView(mContext, contentRes));
    }

    public void setContentView(View view) {
        contentContainer.removeAllViews();
        if (view == null) return;
        contentContainer.addView(view);
    }


}
